<template>
  <div class="mui-numbox" data-numbox-min="1">
    <button class="mui-btn mui-btn-numbox-minus" type="button">-</button>
    <input
      id="test"
      class="mui-input-numbox"
      type="number"
      :value="initcount"
      ref="numbox"
      @change="countChanged"
      onlyread
    />
    <button class="mui-btn mui-btn-numbox-plus" type="button">+</button>
  </div>

  <!-- 分析： 子组件什么时候把 数据传递给父组件 -->
  <!--  -->
</template>

<script>
import mui from "../../src/lib/mui/js/mui.js";

export default {
  mounted() {
    // 初始化数字选择框组件
    mui(".mui-numbox").numbox();
    // console.log(this.max);
    this.$store.commit("numChanged", this.$refs.numbox.value);
  },
  methods: {
    countChanged() {
      this.$store.commit("updateGoodsInfo", {
        id: this.id,
        count: this.$refs.numbox.value
      });
    }
  },
  props: ["initcount", "id"]
};
</script>

<style lang="scss" scoped>
</style>
